package com.cloud.spider.controller.v1;

import com.cloud.spider.dtos.CrawlNovelRequestDto;
import com.cloud.spider.dtos.ResponseResult;
import com.cloud.spider.service.PublicCrawlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 柳晓宇
 * @description
 * @create 2023/10/22
 */
@RestController
@RequestMapping("/api/v1/crawl")
public class CrawlerController {
    private final PublicCrawlerService publicCrawlerService;

    @Autowired
    public CrawlerController(PublicCrawlerService publicCrawlerService){
        this.publicCrawlerService = publicCrawlerService;
    }

    @GetMapping(value = "/parse")
    public ResponseResult crawl(CrawlNovelRequestDto dto){
        return publicCrawlerService.parse(dto);
    }

    @GetMapping(value = "/test")
    public ResponseResult test(CrawlNovelRequestDto dto){
        return publicCrawlerService.pageParseTest(dto);
    }
}
